/*
 * JCartesiano.java
 *
 * Created on 2 de Junho de 2007, 11:36
 */

package dharsudoku.gui.testes;

/**
 *
 * @author  rodrigo
 */
public class JCartesiano extends javax.swing.JFrame {
    
    /**
	 * Creates new form JCartesiano
	 */
    public JCartesiano() {
	initComponents();
	
	canvasG.addMouseListener((CanvasGrafo)canvasG);
	canvasH.addMouseListener((CanvasGrafo)canvasH);
	canvasG.addMouseMotionListener((CanvasGrafo)canvasG);
	canvasH.addMouseMotionListener((CanvasGrafo)canvasH);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        panelG = new javax.swing.JPanel();
        canvasG = new CanvasGrafo();
        buttonLimparG = new javax.swing.JButton();
        panelH = new javax.swing.JPanel();
        canvasH = new CanvasGrafo();
        buttonLimparH = new javax.swing.JButton();
        panelGxH = new javax.swing.JPanel();
        canvasGxH = new CanvasGrafo();
        executar = new javax.swing.JButton();
        labelX = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Produto Cartesiano");
        setName("frameCartesiano");
        setResizable(false);
        panelG.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        canvasG.setBackground(new java.awt.Color(255, 255, 255));

        buttonLimparG.setText("Limpar");
        buttonLimparG.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonLimparGActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout panelGLayout = new org.jdesktop.layout.GroupLayout(panelG);
        panelG.setLayout(panelGLayout);
        panelGLayout.setHorizontalGroup(
            panelGLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panelGLayout.createSequentialGroup()
                .addContainerGap()
                .add(panelGLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, buttonLimparG)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, canvasG, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 252, Short.MAX_VALUE)))
        );
        panelGLayout.setVerticalGroup(
            panelGLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, panelGLayout.createSequentialGroup()
                .add(canvasG, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 235, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(buttonLimparG))
        );

        panelH.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        canvasH.setBackground(new java.awt.Color(255, 255, 255));

        buttonLimparH.setText("Limpar");
        buttonLimparH.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonLimparHActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout panelHLayout = new org.jdesktop.layout.GroupLayout(panelH);
        panelH.setLayout(panelHLayout);
        panelHLayout.setHorizontalGroup(
            panelHLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, canvasH, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 252, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, buttonLimparH)
        );
        panelHLayout.setVerticalGroup(
            panelHLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panelHLayout.createSequentialGroup()
                .add(canvasH, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 231, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 12, Short.MAX_VALUE)
                .add(buttonLimparH))
        );

        panelGxH.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        canvasGxH.setBackground(new java.awt.Color(255, 255, 255));

        org.jdesktop.layout.GroupLayout panelGxHLayout = new org.jdesktop.layout.GroupLayout(panelGxH);
        panelGxH.setLayout(panelGxHLayout);
        panelGxHLayout.setHorizontalGroup(
            panelGxHLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(canvasGxH, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 252, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
        );
        panelGxHLayout.setVerticalGroup(
            panelGxHLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(canvasGxH, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 231, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
        );

        executar.setText("=");
        executar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                executarActionPerformed(evt);
            }
        });

        labelX.setText("X");

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(panelG, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(labelX, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 16, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(1, 1, 1)
                .add(panelH, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(executar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 59, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(panelGxH, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(119, 119, 119)
                        .add(executar))
                    .add(layout.createSequentialGroup()
                        .addContainerGap()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, panelG, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 278, Short.MAX_VALUE)
                            .add(panelH, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(layout.createSequentialGroup()
                                .add(117, 117, 117)
                                .add(labelX))
                            .add(panelGxH, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap())
        );
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-930)/2, (screenSize.height-331)/2, 930, 331);
    }// </editor-fold>//GEN-END:initComponents

    private void buttonLimparHActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonLimparHActionPerformed
	((CanvasGrafo)canvasH).clear();
    }//GEN-LAST:event_buttonLimparHActionPerformed

    private void buttonLimparGActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonLimparGActionPerformed
	((CanvasGrafo)canvasG).clear();
    }//GEN-LAST:event_buttonLimparGActionPerformed

    private void executarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_executarActionPerformed

	((CanvasGrafo)canvasGxH).setGrafo(((CanvasGrafo)canvasG).getGrafo().getProdutoCartesiano((((CanvasGrafo)canvasH).getGrafo())));
    }//GEN-LAST:event_executarActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
	java.awt.EventQueue.invokeLater(new Runnable() {
	    public void run() {
		new JCartesiano().setVisible(true);
	    }
	});
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonLimparG;
    private javax.swing.JButton buttonLimparH;
    private java.awt.Canvas canvasG;
    private java.awt.Canvas canvasGxH;
    private java.awt.Canvas canvasH;
    private javax.swing.JButton executar;
    private javax.swing.JLabel labelX;
    private javax.swing.JPanel panelG;
    private javax.swing.JPanel panelGxH;
    private javax.swing.JPanel panelH;
    // End of variables declaration//GEN-END:variables
    
}
